@extends('Admin.base')
@section('css')
    <link rel="stylesheet" href="/Admin/layuiadmin/css/extend/formSelects-v4.css" media="all">
    <style>
        .layui-form-label {
            width: 308px;
        }
        .layui-input, .layui-textarea {
            width: 60%;
        }
        .layui-input-block {
            margin-left: 363px;
            min-height: 36px;
        }

    </style>
@endsection
@section('content')
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>运费配置</legend>
            </fieldset>
        </div>
        <div class="layui-card-body">
            <form class="layui-form " id="layui-form" action="{{route('post.configSave')}}" method="post" >
                <div class="layui-form-item" >
                    <label class="layui-form-label">是否免运费</label>
                    <div class="layui-input-block">
                        <input type="checkbox" lay-filter="fare"  name="fare" lay-text="是|否"   id="fare"  {{(isset($fare) && $fare == \App\Models\GlobalConfig::FARE_IS) ? 'checked' : ''}} lay-skin="switch">
                    </div>
                </div>
                <div class="contion"  >
                <div class="layui-form-mid layui-word-aux">免费运费条件:</div>
                <div class="layui-form-item" >
                    <label class="layui-form-label"> <input class="layui-inline" type="radio" name="fare_condition" value="1"  {{$fare_condition==1 ? 'checked' :''}}>单次购买金额超出一定数量免除运费:</label>
                    <div class="layui-input-block">
                        <input type="text"  name="fare_condition1"  value="{{$fare_condition1 ?? ''}}"  lay-verify="number" placeholder="请输入金额" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item " >
                    <label class="layui-form-label"> <input type="radio" name="fare_condition" value="2"  {{$fare_condition==2 ? 'checked' :''}}>单次购买商品数量超出一定数量免除运费:</label>
                    <div class="layui-input-block">
                        <input type="text" name="fare_condition2"  value="{{$fare_condition2 ?? ''}}"  lay-verify="number" placeholder="请输入商品数量" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">首重(g)：</label>
                    <div class="layui-input-block">
                        <input type="text" name="first_weight"  value="{{$first_weight ?? ''}}"   lay-verify="number"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">首重金额(元)：</label>
                    <div class="layui-input-block">
                        <input type="text" name="first_money"  value="{{$first_money ?? ''}}"  lay-verify="number"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">每超出1000g金额(元)：</label>
                    <div class="layui-input-block">
                        <input type="text" name="every_up_money"  value="{{$every_up_money ?? ''}}"  lay-verify="number"  class="layui-input">
                    </div>
                </div>
                </div>
                {{method_field('PUT')}}
                {{csrf_field()}}
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="reset" class="layui-btn layui-btn-primary">取消</button>
                        <button type="submit" class="layui-btn" lay-submit="" lay-filter="layui-form-submit">保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection
@section('script')
    <script src="/js/ajax.js"></script>
    <script>
        layui.use(['form', 'table','laydate'], function() {
            var $ = layui.$;
            var form = layui.form;
            $("#fare").attr("checked") == "checked" ?  $(".contion").css('display','none') : $(".contion").css('display','');
            form.on('switch(fare)', function(data){
                if(data.elem.checked){
                    $(".contion").css('display','none');
                }else{
                    $(".contion").css('display','');
                }
            });

        })
    </script>
@endsection
